package com.example.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils

/**
 * 跳转封装
 */
class ARouterService:NavigationCallback {
     override fun onFound(postcard: Postcard?) {

     }

     override fun onLost(postcard: Postcard?) {
         ToastUtils.showLong("找不到路径:${postcard?.path}")
         postcard?.context.let {
             ARouter.getInstance().build("/app/NotFoundActivity").navigation()
         }
     }

     override fun onArrival(postcard: Postcard?) {

     }

     override fun onInterrupt(postcard: Postcard?) {

     }
    object ARouterManager{
        fun navigation(context: Context,path:String,key:String?="",para:String?=""){
            ARouter.getInstance().build(path).withString(key,para).navigation(context,ARouterService())
        }
    }
 }